
#ifndef SINGLEWIRESERIAL_H 
#define SINGLEWIRESERIAL_H 

#ifdef __cplusplus
extern "C"{
#endif

/*----------------------------------include-----------------------------------*/
#include "cpu.h"
#include "gptimer.h"
/*-----------------------------------macro------------------------------------*/

/*----------------------------------typedef-----------------------------------*/
typedef void * SingleWireSerial_Handle_t;
typedef void (*SingleWireSerial_PostHandler_t)(SingleWireSerial_Handle_t handle,u8* rxDataBuf, u16 len);

/**
 * @brief A Handler use for detect trigger signal when the bus is free
 * @author zhengziyang (zhengziyang@zh-jieli.com)
 */
typedef bool (*SingleWireSerial_TriggerDectectHandler_t)(void *priv);

/**
 * @brief Get Signal value
 * @author zhengziyang (zhengziyang@zh-jieli.com)
 */
typedef u8 SingleWireSerial_GetValueHandler_t(void *private);
/*----------------------------------variable----------------------------------*/

/*-------------------------------------os-------------------------------------*/

/*----------------------------------function----------------------------------*/
SingleWireSerial_Handle_t SingleWireSerial_CreateHandle(u16 bitNums,u8 captureOffsetPercent, 
                                                        u32 BitPeriod_us,
                                                        SingleWireSerial_PostHandler_t postHandler,
                                                        SingleWireSerial_TriggerDectectHandler_t detectorHandler,
                                                        void * dectectorPriv,
                                                        u8 (*getValueCB)(void),
                                                        u32 scanGap_inFreeState_us);
void SingleWireSerial_DestroyHandle(SingleWireSerial_Handle_t handle);
void SingleWireSerial_StartRecieve(SingleWireSerial_Handle_t handle);
/*------------------------------------test------------------------------------*/


extern SingleWireSerial_Handle_t ChargeMessageReceiver;

#ifdef __cplusplus
}
#endif

#endif	/* SINGLEWIRESERIAL_H */
